$(document).ready(function (){


var index_list_url = "knowledge/logsample/querySimpleList";

var index_list_col_header = [
							  {name:"",text:"" ,hideSearch:"hide",width:3},
							  {text : "样本ID" ,name : "sampleId",align:"left",width:20,hideSearch:true},
							  {text : "设备类型名称" ,name : "devtypeName",align:"left",width:17},
							  {text : "应用警告名称" ,name : "alarmName",align:"left",width:20},
							  {text : "样本名称" ,name : "pattenName",align:"left",width:20},
							  {text : "样本描述" ,name : "pattenDesc",align:"left",width:20}
							];

var index_list_col_oper = [
				  			  {icon : "rh-icon rh-edit" ,text : "修改" ,aclick :update_template_init}
			   			  ];

var list_updetail_url = "knowledge/logsample/queryDetailSimpleInfo";

var list_update_url = "knowledge/logsample/updSimpleInfo";

index_list_get({paramObj:null,isLoad:true,maskObj:"body"});

function index_list_get(option)
{
	g_grid.render($("#table_div") ,{
 		header : index_list_col_header,
 		oper : index_list_col_oper,
 		operWidth : "60px",
 		url : index_list_url,
 		paramObj : option.paramObj,
 		isLoad : option.isLoad,
 		maskObj : option.maskObj,
 		allowCheckBox:false,
 		dbIndex:1,
 		dbClick : detail_template_init,
 		hasBorder : false,
		autoHeight : true,
		showCount : true
	});
}

function update_template_init (rowData)
{
	$.ajax({
		type: "GET",
		url: "module/base_resource_mant/sec_event_manage/log_sample_type_tpl.html",
		success : function(data){
			g_dialog.dialog($(data).find("[id=update_template]") ,{
				width : "500px",
				init : init,
				title : "日志样本类型库信息修改",
				saveclick : save_click
			});
		}
	});

	function init (el)
	{
		g_validate.init(el);
		um_ajax_get({
			url:list_updetail_url,
			paramObj:{sampleId:rowData.sampleId},
			isLoad:true,
			maskObj:"body",
			successCallBack:function(data){
				el.umDataBind("render",data[0]);
			}
		});	
	}

	function save_click (el ,saveObj)
	{
		if (!g_validate.validate(el))
		{
			return false;
		}
		um_ajax_post({
			url : list_update_url,
			paramObj : saveObj,
			isLoad:true,
			maskObj:"body",
			successCallBack : function (data){
				g_dialog.hide(el);
				g_dialog.operateAlert();
				index_list_get({paramObj:null,isLoad:true,maskObj:"body"});
			}
		});
	}
}


function detail_template_init(rowData)
{
	$.ajax({
		type: "GET",
		url: "module/base_resource_mant/sec_event_manage/log_sample_type_tpl.html",
		isLoad:true,
		maskObj:"body",
		success :function(data)
		{
			g_dialog.dialog($(data).find("[id=detail_template]"),{
				width : "400px",
				init : init,
				title : "日志样本类型库详细信息",
				isDetail : true
			});
		}
	});

	function init(el)
	{
		um_ajax_get({
			url:list_updetail_url,
			paramObj:{sampleId:rowData.sampleId},
			isLoad:true,
			maskObj:"body",
			successCallBack:function(data){
				el.umDataBind("render",data[0]);
			}
		});	
	}
}


});